import {_decorator, Component, resources, Sprite, SpriteFrame, UIOpacity} from 'cc';
import {utils} from '../../utils/utils';
import Long from "long";
import {userInfo} from "db://assets/script/user-info";
import {FreshImmortal} from "db://assets/proto/shared/v1/wuni";

const {ccclass, property} = _decorator;

@ccclass('HeadComp')
export class HeadComp extends Component {
    @property(Sprite)
    head!: Sprite;

    uiOpacity: UIOpacity | null = null!;

    onLoad() {
        this.uiOpacity = this.getComponent(UIOpacity) || this.addComponent(UIOpacity);
    }


    start() {

    }

    setHead(fishId: Long, gender: number, talent: number, masterId: string) {
        let headUrl = masterId == "0" ? "textures/monster-head/head" : "textures/head/"
        if (masterId != '0') {
            if (talent >= 4) {
                headUrl = headUrl + 'high-talent/' + gender + '/head'
            } else {
                headUrl = headUrl + gender + '/head'
            }
        }
        this.head.spriteFrame = resources.get(headUrl! + fishId.mod(20).add(1).toString() + '/spriteFrame', SpriteFrame)!
    }

    update(deltaTime: number) {

    }
}


